use rbase::define::ApiError;

use rbase::define::IErrorCode;
use rbase_macros::ImplIErrorCode;

// 此角色或用户不能被修改和删除
pub static ADMIN: &str = "admin";

#[derive(ImplIErrorCode, Debug, Clone)]
pub enum IamError {
    #[status_code = 400]
    LoginFailed,

    #[status_code = 400]
    RegisterFailed,

    #[status_code = 403]
    PermissionDenied(String),
}

impl From<IamError> for ApiError {
    fn from(err: IamError) -> Self {
        ApiError::new(err.status_code(), err.get_code().to_string(), "".to_string())
    }
}
